/*
 * Copyright 2021 MindMotion Microelectronics Co., Ltd.
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#ifndef __BOARD_INIT_H__
#define __BOARD_INIT_H__

#include <stdio.h>

#include "hal_common.h"
#include "hal_gpio.h"
#include "hal_uart.h"
#include "hal_tim.h"

#include "clock_init.h"
#include "pin_init.h"

#if 1 /* do not setup debug uart when using at server. */
/* DEBUG UART. */
#define BOARD_DEBUG_UART_PORT        UART1
#define BOARD_DEBUG_UART_BAUDRATE    9600u
#define BOARD_DEBUG_UART_FREQ        CLOCK_APB2_FREQ
#endif

/* DEBUG UART. */
#define BOARD_AT_UART_PORT        UART1
#define BOARD_AT_UART_BAUDRATE    9600u
#define BOARD_AT_UART_FREQ        CLOCK_APB2_FREQ

#define BOARD_AT_UART_IRQn        UART1_IRQn
#define BOARD_AT_UART_IRQHandler  UART1_IRQHandler

/* SERVO SOCKET
* - PA8  - TIM1_CH1(AF1)
* - PA9  - TIM1_CH2(AF1)
* - PA10 - TIM1_CH3(AF1)
* - PC8  - TIM3_CH3(AF2)
* - PB4  - TIM3_CH1(AF2)
* - PB5  - TIM3_CH2(AF2)
*/



#define BOARD_SERVO_PWM_012_FREQ  CLOCK_SYS_FREQ //CLOCK_APB2_FREQ
#define BOARD_SERVO_PWM_012_PORT  (TIM_Type *)TIM1
#define BOARD_SERVO_PWM_0_CHN   0u
#define BOARD_SERVO_PWM_1_CHN   1u
#define BOARD_SERVO_PWM_2_CHN   2u

#define BOARD_SERVO_PWM_345_FREQ  CLOCK_SYS_FREQ //CLOCK_APB1_FREQ
#define BOARD_SERVO_PWM_345_PORT  (TIM_Type *)TIM3
#define BOARD_SERVO_PWM_3_CHN   0u
#define BOARD_SERVO_PWM_4_CHN   2u
#define BOARD_SERVO_PWM_5_CHN   1u

void BOARD_Init(void);

#endif /* __BOARD_INIT_H__ */
